<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 主键
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $robot_id 机器人id
 * @property string $sender 回复人id
 * @property string $question_id 问题id
 * @property int $reply_type 1-关键词回复  2-图片回复  3-默认回复
 * @property array $reply_content 回复内容
 * @property int $is_question_list 是否是回复列表
 * @property int $to_id 发送id
 */
class ChSmartAnswerRecord extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_smart_answer_record';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'created_at', 'updated_at', 'robot_id', 'sender', 'question_id', 'reply_type', 'reply_content', 'is_question_list', 'to_id'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'robot_id' => 'integer', 'reply_type' => 'integer', 'reply_content' => 'array', 'is_question_list' => 'integer', 'to_id' => 'integer'];

    public static function saveRecord($robotId,$sender,$tid,$replyType,$replyContent,$questionId=0,$isQuestionList=0)
    {
        $model=new self();
        $model->robot_id=$robotId;
        $model->sender=$sender;
        $model->reply_type=$replyType;
        $model->to_id=$tid;
        $model->reply_content=$replyContent;
        $model->question_id=$questionId;
        $model->is_question_list=$isQuestionList;
        $model->save();
        return $model;
    }
}
